Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
mq()
is a Sass mixin that helps you compose media queries in an elegant
way.
px
/em
values to em
-based queries (a good thing)Here is a very basic example:
$mq-breakpoints: (
mobile: 320px,
tablet: 740px,
desktop: 980px,
wide: 1300px
);
@import 'mq';
.foo {
@include mq($from: mobile, $until: tablet) {
background: red;
}
@include mq($from: tablet) {
background: green;
}
}
Compiles to:
@media (min-width: 20em) and (max-width: 46.24em) {
.foo {
background: red;
}
}
@media (min-width: 46.25em) {
.foo {
background: green;
}
}
Sass MQ was crafted in-house at the Guardian. Today, many more companies and developers are using it in their projects: see who uses Sass MQ.
Immediately play with it on SassMeister: @import 'mq';
.
OR:
Install with Bower: bower install sass-mq --save
OR Install with npm: npm install sass-mq --save
it supports eyeglass
OR Download _mq.scss to your Sass project.
Import the partial in your Sass files and override default settings with your own preferences before the file is imported:
// To enable support for browsers that do not support @media queries,
// (IE <= 8, Firefox <= 3, Opera <= 9) set $mq-responsive to false
// Create a separate stylesheet served exclusively to these browsers,
// meaning @media queries will be rasterized, relying on the cascade itself
$mq-responsive: true;
// Name your breakpoints in a way that creates a ubiquitous language
// across team members. It will improve communication between
// stakeholders, designers, developers, and testers.
$mq-breakpoints: (
mobile: 320px,
tablet: 740px,
desktop: 980px,
wide: 1300px,
// Tweakpoints
desktopAd: 810px,
mobileLandscape: 480px
);
// Define the breakpoint from the $mq-breakpoints list that should
// be used as the target width when outputting a static stylesheet
// (i.e. when $mq-responsive is set to 'false').
$mq-static-breakpoint: desktop;
// If you want to display the currently active breakpoint in the top
// right corner of your site during development, add the breakpoints
// to this list, ordered by width, e.g. (mobile, tablet, desktop).
$mq-show-breakpoints: (mobile, mobileLandscape, tablet, desktop, wide);
@import 'path/to/mq';
// With eyeglass:
// @import 'sass-mq';
Play around with mq()
(see below)
mq()
takes up to three optional parameters:
$from
: inclusive min-width
boundary$until
: exclusive max-width
boundary$and
: additional custom directivesNote that $until
as a keyword is a hard limit i.e. it's breakpoint - 1.
.responsive {
// Apply styling to mobile and upwards
@include mq($from: mobile) {
color: red;
}
// Apply styling up to devices smaller than tablets (exclude tablets)
@include mq($until: tablet) {
color: blue;
}
// Same thing, in landscape orientation
@include mq($until: tablet, $and: '(orientation: landscape)') {
color: hotpink;
}
// Apply styling to tablets up to desktop (exclude desktop)
@include mq(tablet, desktop) {
color: green;
}
}
To enable support for browsers that do not support @media
queries,
(IE <= 8, Firefox <= 3, Opera <= 9) set $mq-responsive: false
.
Tip: create a separate stylesheet served exclusively to these browsers, for example with conditional comments.
When @media
queries are rasterized, browsers rely on the cascade
itself. Learn more about this technique on Jake’s blog.
To avoid rasterizing styles intended for displays larger than what those
older browsers typically run on, set $mq-static-breakpoint
to match
a breakpoint from the $mq-breakpoints
list. The default is
desktop
.
The static output will only include @media
queries that start at or
span this breakpoint and which have no custom $and
directives:
$mq-responsive: false;
$mq-static-breakpoint: desktop;
.static {
// Queries that span or start at desktop are compiled:
@include mq($from: mobile) {
color: lawngreen;
}
@include mq(tablet, wide) {
color: seagreen;
}
@include mq($from: desktop) {
color: forestgreen;
}
// But these queries won’t be compiled:
@include mq($until: tablet) {
color: indianred;
}
@include mq($until: tablet, $and: '(orientation: landscape)') {
color: crimson;
}
@include mq(mobile, desktop) {
color: firebrick;
}
}
@include mq-add-breakpoint(tvscreen, 1920px);
.hide-on-tv {
@include mq(tvscreen) {
display: none;
}
}
While developing, it can be nice to always know which breakpoint is
active. To achieve this, set the $mq-show-breakpoints
variable to
be a list of the breakpoints you want to debug, ordered by width.
The name of the active breakpoint and its pixel and em values will
then be shown in the top right corner of the viewport.
If you want to specify a media type, for example to output styles
for screens only, set $mq-media-type
:
$mq-media-type: screen;
.screen-only-element {
@include mq(mobile) {
width: 300px;
}
}
@media screen and (max-width: 19.99em) {
.screen-only-element {
width: 300px;
}
}
npm test
Sass MQ is documented using SassDoc.
Generate the documentation locally:
sassdoc .
Generate & deploy the documentation to http://sass-mq.github.io/sass-mq/:
npm run sassdoc
Sass MQ was developed in-house at the Guardian.
These companies and projects use Sass MQ:
Looking for a more advanced sass-mq, with support for height and other niceties?
Give @mcaskill's fork of sass-mq a try.
FAQs
mq() is a Sass mixin that helps manipulating media queries in an elegant way.
The npm package sass-mq receives a total of 59,203 weekly downloads. As such, sass-mq popularity was classified as popular.
We found that sass-mq demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.